bitkeeper revision 1.22.1.3 (3e3fc1b6-8OCS9mBQJHT5qOSCxbykw)
authorkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>
Tue, 4 Feb 2003 13:35:50 +0000 (13:35 +0000)
committerkaf24@labyrinth.cl.cam.ac.uk <kaf24@labyrinth.cl.cam.ac.uk>
Tue, 4 Feb 2003 13:35:50 +0000 (13:35 +0000)
Many files:
  Cleaned up domain-builder interface. MPT entries are now initialised at build time.

xen-2.4.16/common/dom0_ops.c
xen-2.4.16/common/domain.c
xen-2.4.16/common/memory.c
xen-2.4.16/include/hypervisor-ifs/hypervisor-if.h
xen-2.4.16/include/xeno/dom0_ops.h
xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_core.c
xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_memory.c
xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/dom0_ops.h
xenolinux-2.4.16-sparse/arch/xeno/drivers/dom0/hypervisor_defs.h

index ddfb454e8b4be244cb453c34e02437f472e0d119..64ac9f6308a661d882e08da99ee3526e1f85d87c 100644 (file)
@@ -1,4 +1,3 @@
-
 /******************************************************************************
  * dom0_ops.c
  * 
@@ -143,13 +142,18 @@ long do_dom0_op(dom0_op_t *u_dom0_op)
     }
     break;
 
-    case DOM0_MAPTASK:
+    case DOM0_GETMEMLIST:
     {
-        unsigned int dom = op.u.mapdomts.domain;
-        
-        op.u.mapdomts.ts_phy_addr = __pa(find_domain_by_id(dom));
-        copy_to_user(u_dom0_op, &op, sizeof(op));
+        int i;
+        unsigned long pfn = op.u.getmemlist.start_pfn;
+        unsigned long *buffer = op.u.getmemlist.buffer;
 
+        for ( i = 0; i < op.u.getmemlist.num_pfns; i++ )
+        {
+            /* XXX We trust DOM0 to give us a safe buffer. XXX */
+            *buffer++ = pfn;
+            pfn = (frame_table + pfn)->next;
+        }
     }
     break;
 
index e1ae666f6243437f5a3632083aa484c4dd47949b..397a8dceb0a738d5a3e41e11d6aab257a0e1bbcf 100644 (file)
@@ -564,12 +564,10 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
     unsigned long phys_l1tab, phys_l2tab;
     unsigned long cur_address, alloc_address;
     unsigned long virt_load_address, virt_stack_address, virt_shinfo_address;
-    unsigned long virt_ftable_start, virt_ftable_end, ft_mapping;
     start_info_t  *virt_startinfo_address;
     unsigned long long time;
     unsigned long count;
     unsigned long alloc_index;
-    unsigned long ft_pages;
     l2_pgentry_t *l2tab, *l2start;
     l1_pgentry_t *l1tab = NULL, *l1start = NULL;
     struct pfn_info *page = NULL;
@@ -626,17 +624,13 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
     p->mm.pagetable = mk_pagetable(phys_l2tab);
 
     /*
-     * NB. The upper limit on this loop does one extra page + pages for frame
-     * table. This is to make sure a pte exists when we want to map the
-     * shared_info struct and frame table struct.
+     * NB. The upper limit on this loop does one extra page. This is to make 
+     * sure a pte exists when we want to map the shared_info struct.
      */
 
-    ft_pages = frame_table_size >> PAGE_SHIFT;
     l2tab += l2_table_offset(virt_load_address);
     cur_address = p->pg_head << PAGE_SHIFT;
-    for ( count  = 0;
-          count < p->tot_pages + 1 + ft_pages;
-          count++)
+    for ( count = 0; count < p->tot_pages + 1; count++ )
     {
         if ( !((unsigned long)l1tab & (PAGE_SIZE-1)) )
         {
@@ -650,11 +644,13 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
         }
         *l1tab++ = mk_l1_pgentry(cur_address|L1_PROT);
         
-        if(count < p->tot_pages)
+        if ( count < p->tot_pages )
         {
             page = frame_table + (cur_address >> PAGE_SHIFT);
             page->flags = dom | PGT_writeable_page;
             page->type_count = page->tot_count = 1;
+            /* Set up the MPT entry. */
+            machine_to_phys_mapping[cur_address >> PAGE_SHIFT] = count;
         }
 
         cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
@@ -663,9 +659,8 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
 
     /* pages that are part of page tables must be read only */
     cur_address = p->pg_head << PAGE_SHIFT;
-    for(count = 0;
-        count < alloc_index;
-        count++){
+    for ( count = 0; count < alloc_index; count++ ) 
+    {
         cur_address = ((frame_table + (cur_address >> PAGE_SHIFT))->next) << PAGE_SHIFT;
     }
 
@@ -674,11 +669,11 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
     l1start = l1tab = map_domain_mem(l2_pgentry_to_phys(*l2tab));
     l1tab += l1_table_offset(virt_load_address + (alloc_index << PAGE_SHIFT));
     l2tab++;
-    for(count = alloc_index;
-        count < p->tot_pages;
-        count++){
+    for ( count = alloc_index; count < p->tot_pages; count++ ) 
+    {
         *l1tab++ = mk_l1_pgentry(l1_pgentry_val(*l1tab) & ~_PAGE_RW);
-        if(!((unsigned long)l1tab & (PAGE_SIZE - 1))){
+        if( !((unsigned long)l1tab & (PAGE_SIZE - 1)) )
+        {
             unmap_domain_mem(l1start);
             l1start = l1tab = map_domain_mem(l2_pgentry_to_phys(*l2tab));
             l2tab++;
@@ -709,21 +704,6 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
     virt_startinfo_address = (start_info_t *)
         (virt_load_address + ((alloc_index - 1) << PAGE_SHIFT));
     virt_stack_address  = (unsigned long)virt_startinfo_address;
-
-    /* set up frame_table mapping */
-    ft_mapping = (unsigned long)frame_table;
-    virt_ftable_start = virt_shinfo_address + PAGE_SIZE; 
-    virt_ftable_end = virt_ftable_start + frame_table_size;
-    for(cur_address = virt_ftable_start;
-        cur_address < virt_ftable_end;
-        cur_address += PAGE_SIZE){
-        l2tab = l2start + l2_table_offset(cur_address);
-        l1start = l1tab = map_domain_mem(l2_pgentry_to_phys(*l2tab));
-        l1tab += l1_table_offset(cur_address);
-        *l1tab = mk_l1_pgentry(__pa(ft_mapping)|L1_PROT);
-        unmap_domain_mem(l1start);
-        ft_mapping += PAGE_SIZE;
-    }
     
     unmap_domain_mem(l2start);
 
@@ -745,7 +725,6 @@ int setup_guestos(struct task_struct *p, dom0_newdomain_t *params)
     virt_startinfo_address->pt_base = virt_load_address + 
         ((p->tot_pages - 1) << PAGE_SHIFT); 
     virt_startinfo_address->phys_base = p->pg_head << PAGE_SHIFT;
-    virt_startinfo_address->frame_table = virt_ftable_start;
 
     /* Add virtual network interfaces and point to them in startinfo. */
     while (params->num_vifs-- > 0) {
index 03fa29a2e0f7bfecbb37d0078b24cd08fe8a573c..2bd0a0d11e9a82a2044f14648729073053865445 100644 (file)
 #include <asm/uaccess.h>
 #include <asm/domain_page.h>
 
-#if 0
+#if 1
 #define MEM_LOG(_f, _a...) printk("DOM%d: (file=memory.c, line=%d) " _f "\n", current->domain, __LINE__, ## _a )
 #else
 #define MEM_LOG(_f, _a...) ((void)0)
@@ -760,6 +760,11 @@ int do_process_page_updates_bh(page_update_request_t * cur, int count)
                     break;
                 }
             }
+            else
+            {
+                MEM_LOG("Bad domain normal update (dom %d, pfn %ld)",
+                        current->domain, pfn);
+            }
             break;
 
         case PGREQ_MPT_UPDATE:
@@ -767,6 +772,12 @@ int do_process_page_updates_bh(page_update_request_t * cur, int count)
             if ( DOMAIN_OKAY(page->flags) )
             {
                 machine_to_phys_mapping[pfn] = cur->val;
+                err = 0;
+            }
+            else
+            {
+                MEM_LOG("Bad domain MPT update (dom %d, pfn %ld)",
+                        current->domain, pfn);
             }
             break;
 
index 96826f5afd0aa260324f3c2af16e7bebfb7ddaa5..9017d0ef58423d78dbd44012aa6f9402528b899d 100644 (file)
@@ -205,7 +205,6 @@ typedef struct start_info_st {
     net_ring_t *net_rings;
     int num_net_rings;
     blk_ring_t *blk_ring;         /* block io communication rings */
-    unsigned long frame_table;
     unsigned char cmd_line[1];    /* variable-length */
 } start_info_t;
 
index 018bde61ae51f93b4017f5a2176de110b0cc9e3b..da82ada596bd56d23d8a8cde7ecc664e535e73f7 100644 (file)
@@ -1,4 +1,3 @@
-
 /******************************************************************************
  * dom0_ops.h
  * 
@@ -12,7 +11,7 @@
 
 #define DOM0_NEWDOMAIN   0
 #define DOM0_KILLDOMAIN  1
-#define DOM0_MAPTASK     2
+#define DOM0_GETMEMLIST  2
 #define DOM0_STARTDOM    4
 
 #define MAX_CMD_LEN    256
@@ -30,11 +29,12 @@ typedef struct dom0_killdomain_st
     unsigned int domain;
 } dom0_killdomain_t;
 
-typedef struct dom0_map_ts
+typedef struct dom0_getmemlist_st
 {
-    unsigned int domain;
-    unsigned long ts_phy_addr;
-} dom0_tsmap_t;
+    unsigned long start_pfn;
+    unsigned long num_pfns;
+    void *buffer;
+} dom0_getmemlist_t;
 
 typedef struct domain_launch
 {
@@ -56,7 +56,7 @@ typedef struct dom0_op_st
     {
         dom0_newdomain_t newdomain;
         dom0_killdomain_t killdomain;
-        dom0_tsmap_t mapdomts;
+        dom0_getmemlist_t getmemlist;
         dom_meminfo_t meminfo;
     }
     u;
index e4bb8260976cf52ffd40215cb2f80f32de8e7dc3..1321f3eb5267bd2ffbb25fa5ad77294539c7d888 100644 (file)
@@ -43,8 +43,6 @@
 
 #define MAP_DISCONT     1
 
-frame_table_t * frame_table;
-
 static struct proc_dir_entry *xeno_base;
 static struct proc_dir_entry *dom0_cmd_intf;
 static struct proc_dir_entry *proc_ft;
@@ -238,8 +236,6 @@ out:
 
 static int __init init_module(void)
 {
-    frame_table = (frame_table_t *)start_info.frame_table;
-    
     /* xeno proc root setup */
     xeno_base = proc_mkdir(XENO_BASE, &proc_root); 
 
index 19a0ce7667c54ea5f5dc7a4ef9a7bf9111725505..55e0495ab033131de9e9d82c9d32639ad51ca98d 100644 (file)
@@ -1,4 +1,3 @@
-
 #include <linux/slab.h>
 #include <linux/mm.h>
 #include <linux/mman.h>
@@ -16,6 +15,7 @@
 #include <asm/mmu.h>
 
 #include "hypervisor_defs.h"
+#include "dom0_ops.h"
 
 #define MAP_CONT    0
 #define MAP_DISCONT 1
@@ -126,26 +126,36 @@ int direct_remap_page_range(unsigned long from, unsigned long phys_addr, unsigne
 int direct_remap_disc_page_range(unsigned long from, 
                 unsigned long first_pg, int tot_pages, pgprot_t prot)
 {
-    frame_table_t * current_ft;
-    unsigned long current_pfn;
+    dom0_op_t dom0_op;
+    unsigned long *pfns = get_free_page(GFP_KERNEL);
     unsigned long start = from;
-    int count = 0;
-
-    current_ft = frame_table + first_pg;
-    current_pfn = first_pg; 
-    while(count < tot_pages){
-            if(direct_remap_page_range(start, current_pfn << PAGE_SHIFT, 
-                PAGE_SIZE, prot))
+    int pages, i;
+
+    while ( tot_pages != 0 )
+    {
+        dom0_op.cmd = DOM0_GETMEMLIST;
+        dom0_op.u.getmemlist.start_pfn = first_pg;
+        pages = 1023;
+        dom0_op.u.getmemlist.num_pfns = 1024;
+        if ( tot_pages < 1024 )
+            dom0_op.u.getmemlist.num_pfns = pages = tot_pages;
+        dom0_op.u.getmemlist.buffer = pfns;
+        (void)HYPERVISOR_dom0_op(&dom0_op);
+        first_pg = pfns[1023]; 
+
+        for ( i = 0; i < pages; i++ )
+        {
+            if(direct_remap_page_range(start, pfns[i] << PAGE_SHIFT, 
+                                       PAGE_SIZE, prot))
                 goto out;
             start += PAGE_SIZE;
-            current_pfn = current_ft->next;
-            current_ft = (frame_table_t *)(frame_table + current_pfn);
-            count++;
+            tot_pages--;
+        }
     }
 
 out:
-
-    return tot_pages - count;
+    free_page(pfns);
+    return tot_pages;
 } 
            
 /* below functions replace standard sys_mmap and sys_munmap which are absolutely useless
@@ -175,8 +185,8 @@ unsigned long direct_mmap(unsigned long phys_addr, unsigned long size,
     }
 
     /* add node on the list of directly mapped areas, make sure the
-        * list remains sorted.
-        */ 
+     * list remains sorted.
+     */ 
     dmmap = (direct_mmap_node_t *)kmalloc(sizeof(direct_mmap_node_t), GFP_KERNEL);
     dmmap->vm_start = addr;
     dmmap->vm_end = addr + size;
index dbb0b3ac726f4c5e4e7890804a21cf750657be6a..502c97e768238ef747a4e65afc83dea60bd18c83 100644 (file)
@@ -8,7 +8,7 @@
 
 #define DOM0_NEWDOMAIN   0
 #define DOM0_KILLDOMAIN  1
-#define DOM0_MAPTASK     2
+#define DOM0_GETMEMLIST  2
 #define MAP_DOM_MEM      3
 #define DOM0_STARTDOM    4
 #define MAX_CMD          4
@@ -28,11 +28,12 @@ typedef struct dom0_killdomain_st
     unsigned int domain;
 } dom0_killdomain_t;
 
-typedef struct dom0_map_ts
+typedef struct dom0_getmemlist_st
 {
-    unsigned int domain;
-    unsigned long ts_phy_addr;
-} dom0_tsmap_t;
+    unsigned long start_pfn;
+    unsigned long num_pfns;
+    void *buffer;
+} dom0_getmemlist_t;
 
 typedef struct dom_mem 
 {
@@ -62,7 +63,7 @@ typedef struct dom0_op_st
     {
         dom0_newdomain_t newdomain;
         dom0_killdomain_t killdomain;
-        dom0_tsmap_t mapdomts;
+        dom0_getmemlist_t getmemlist;
         dom_mem_t dommem;
         dom_meminfo_t meminfo;
     }
index ee047735ddb78d548bb394baaf0f662248b6509b..e2965ff6a4fb731a1ca469ad7638f0f96b8c07d2 100644 (file)
  */
 
 
-/* original version: xen-2.4.16/include/xeno/mm.h */
-typedef struct pfn_info {
-    struct list_head list;      /* ->mapping has some page lists. */
-    unsigned long next;         /* used for threading pages belonging */
-    unsigned long prev;         /* to same domain */
-    unsigned long flags;        /* atomic flags. */
-    unsigned long tot_count;    /* Total domain usage count. */
-    unsigned long type_count;   /* pagetable/dir, or domain-writeable refs. */
-} frame_table_t;
-
-extern frame_table_t * frame_table;
-
 typedef struct proc_data {
     unsigned int domain;
     unsigned long map_size;